﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using VirtualPress.Tool.Configration;
using VirtualPress.Tool.Framework;

namespace VirtualPress.Engine.ExServer.WorkPool.WorkHandle.Email
{
    internal abstract class BaseEmailHandle<T> : IWorkHandle<T>
    {
        string partition = string.Empty;
        protected virtual void Prepare(EmailContext ctx, string partition="account")
        {
            this.partition = partition;
            var serveritem = ConfigReader.WorkPool.EmailQueue.Pool[partition].ServerList.RandomGet();
            ctx.From = serveritem.Address;
            ctx.CredentialPassword = serveritem.Password;// System.Configuration.ConfigurationManager.AppSettings["EMail-Password"];
            ctx.CredentialUserName = serveritem.Username;// System.Configuration.ConfigurationManager.AppSettings["Email-UserName"];
        }
        protected void SendMailCallBack(EmailContext context)
        {
            if (ConfigReader.WorkPool.EmailQueue.Pool[this.partition].Enable)
            {
                new EMail(context).Send();
            }
        }

        #region IWorkHandle<T> 成员

        public abstract WaitWorkItem Process(T context);

        #endregion
    }

    #region Account相关
    ///// <summary>
    ///// 注册邮件
    ///// </summary>
    //internal class EmailForRegisterHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        AccountEmail emailctx = context as AccountEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        #region 赋值Context对象
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "account");
    //        ctx.Subject = SiteResource.SiteName+ "--账号激活邮件";
    //        ctx.DisplayName = SiteResource.SiteName;
    //        ctx.Body = BuildWelcomeEmailBody(emailctx.Recipient, emailctx.Token);
    //        data.Context = ctx;
    //        #endregion

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    /// <summary>
    //    /// 构建注册激活邮件内容
    //    /// </summary>
    //    /// <param name="username"></param>
    //    /// <param name="token">注册时生成的token值</param>
    //    /// <returns></returns>
    //    public string BuildWelcomeEmailBody(string username, string fixtoken)
    //    {
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>尊敬的用户：" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>欢迎您注册"+SiteResource.SiteName+"，请点击以下链接激活您的账号</p>");
    //        sb.AppendLine("<p><a href=\"http://" + SiteResource.Domain + "/account/activation?token=" + fixtoken + "\">http://" +
    //            SiteResource.Domain + "/account/activation?token=" + fixtoken + "</a></p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>"); 
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
    //}
    //internal class EmailForResetPwdHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        AccountEmail emailctx = context as AccountEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        #region 赋值Context对象
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "account");
    //        ctx.Subject = SiteResource.SiteName + "--密码重置验证";
    //        ctx.Body = BuildResetPasswordEmailBody(emailctx.Recipient, emailctx.Token);
    //        data.Context = ctx;
    //        #endregion

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildResetPasswordEmailBody(string username, string fixtoken)
    //    {
    //        string url = "http://"+SiteResource.Domain+"/account/resetpassword?token=" + fixtoken + "&u=" + EncodeByBase64.Encode(username);
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>尊敬会员：" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>您在"+SiteResource.SiteName+"申请了重置密码。请点击以下链接以继续您的操作：</p>");
    //        sb.AppendLine("<p><a href=\"" + url + "\">" + url + "</a></p>");
    //        sb.AppendLine("<p>如果您未申请过重置密码，请尽快<a target=\"_blank\" href=\"http://"+SiteResource.Domain+"/account/login\">登录"+SiteResource.SiteName+"</a>，并修改您的密码</p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>"); 
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }

    //}
    #endregion

    #region Notity
    //internal class EmailForInviteExpertNotityHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        InviteForJournalNotityEmail emailctx = context as InviteForJournalNotityEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 《{1}》邀请您加入编委会", SiteResource.SiteName, emailctx.JournalName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Type, emailctx.Recipient, emailctx.JournalName, emailctx.JournalId, emailctx.JournalLeaguerId);
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(int type, string username, string journalName, int journalId, int journalLeaguerId)
    //    {
    //        string agreeUrl = "http://" + SiteResource.Domain + "/Job/Item?token=" +
    //            EncodeByBase64.Encode(new
    //            {
    //                Type = type,
    //                Stream = new
    //                {
    //                    Agree = true,
    //                    ExpertAccount = username,
    //                    JournalId = journalId,
    //                    JournalLeaguerId = journalLeaguerId
    //                }.ToJson()
    //            }.ToJson());

    //        string refuseUrl = "http://" + SiteResource.Domain + "/Job/Item?token=" +
    //            EncodeByBase64.Encode(new
    //            {
    //                Type = type,
    //                Stream = new
    //                {
    //                    Agree = false,
    //                    ExpertAccount = username,
    //                    JournalId = journalId,
    //                    JournalLeaguerId = journalLeaguerId
    //                }.ToJson()
    //            }.ToJson());

    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>我们是：" + SiteResource.SiteName + "</p>");
    //        sb.AppendLine("<p>《" + journalName + "》 邀请您加入他们的"+(type == 0?"编委会":"初审工作")+"</p>");
    //        sb.AppendLine("<p>如果您<strong style=\"color:green;\">同意</strong>并加入他们的" + (type == 0 ? "编委会" : "初审工作") + "，请点击链接<a href=\"" + agreeUrl + "\">" + agreeUrl + "</a></p>");
    //        sb.AppendLine("<p>如果您<strong style=\"color:red;\">拒绝</strong>加入他们的" + (type == 0 ? "编委会" : "初审工作") + "，请点击链接<a href=\"" + refuseUrl + "\">" + refuseUrl + "</a></p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
    //}
    //internal class EmailForWelcomeExpertHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        WelcomeForExpertEmail emailctx = context as WelcomeForExpertEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 欢迎您的加入", SiteResource.SiteName, emailctx.JournalName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Type, emailctx.Recipient, emailctx.JournalName);
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(int type, string username, string journalName)
    //    {
    //        string url = "http://" + SiteResource.Domain;
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>欢迎您加入" + SiteResource.SiteName + "，您已经成功成为《" + journalName + "》的" + (type == 0 ? "编委会成员" : "初审成员") + "</p>");
    //        sb.AppendLine("<p>您的登陆用户名为："+username+"</p>");
    //        sb.AppendLine("<p>您可以使用如下链接登陆到我们的网站<br/><a href=\"" + url + "\">" + url + "</a></p>");
    //        sb.AppendLine("<p>我们欢迎您的光临!</p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
    //}
    //internal class EmailForInviteReviserNotityHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        InviteForJournalNotityEmail emailctx = context as InviteForJournalNotityEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 《{1}》邀请您加入编审会", SiteResource.SiteName, emailctx.JournalName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Type, emailctx.Recipient, emailctx.JournalName, emailctx.JournalId, emailctx.JournalLeaguerId);
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(int type, string username, string journalName, int journalId, int journalLeaguerId)
    //    {
    //        string agreeUrl = "http://" + SiteResource.Domain + "/Job/Item?token=" +
    //            EncodeByBase64.Encode(new
    //            {
    //                Type = type,
    //                Stream = new
    //                {
    //                    Agree = true,
    //                    ExpertAccount = username,
    //                    JournalId = journalId,
    //                    JournalLeaguerId = journalLeaguerId
    //                }.ToJson()
    //            }.ToJson());

    //        string refuseUrl = "http://" + SiteResource.Domain + "/Job/Item?token=" +
    //            EncodeByBase64.Encode(new
    //            {
    //                Type = type,
    //                Stream = new
    //                {
    //                    Agree = false,
    //                    ExpertAccount = username,
    //                    JournalId = journalId,
    //                    JournalLeaguerId = journalLeaguerId
    //                }.ToJson()
    //            }.ToJson());

    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>我们是：" + SiteResource.SiteName + "</p>");
    //        sb.AppendLine("<p>《" + journalName + "》 邀请您加入他们的" + (type == 0 ? "编委会" : "初审工作") + "</p>");
    //        sb.AppendLine("<p>如果您<strong style=\"color:green;\">同意</strong>并加入他们的" + (type == 0 ? "编委会" : "初审工作") + "，请点击链接<a href=\"" + agreeUrl + "\">" + agreeUrl + "</a></p>");
    //        sb.AppendLine("<p>如果您<strong style=\"color:red;\">拒绝</strong>加入他们的" + (type == 0 ? "编委会" : "初审工作") + "，请点击链接<a href=\"" + refuseUrl + "\">" + refuseUrl + "</a></p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
    //}
    //internal class EmailForJobNotityHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        JobNotityEmail emailctx = context as JobNotityEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 有一项新任务", SiteResource.SiteName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Message, emailctx.Recipient, emailctx.BackUrl);
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(string message, string username, string backurl)
    //    {
    //        string url = "http://" + SiteResource.Domain + backurl;
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>管理员" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>您有一项新待处理项：</p>");
    //        sb.AppendLine("<p>" + message + "</p>");
    //        sb.AppendLine("<p>您可以使用如下链接登陆到我们的网站，并处理该任务<br/><a href=\"" + url + "\">" + url + "</a></p>");
    //        sb.AppendLine("<p>我们欢迎您的光临!</p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
   
    //}
    //internal class EmailForManuscriptCheckHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        ManuscriptCheckEmail emailctx = context as ManuscriptCheckEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 稿件《{1}》初审完成", SiteResource.SiteName, emailctx.ArticleName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Message, emailctx.Recipient, emailctx.BackUrl);
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(string message, string username, string backurl)
    //    {
    //        string url = "http://" + SiteResource.Domain + backurl;
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>" + message + "</p>");
    //        if (!String.IsNullOrEmpty(backurl))
    //        {
    //            sb.AppendLine("<p>您可以使用如下链接登陆到我们的网站，并进行后续的操作<br/><a href=\"" + url + "\">" + url + "</a></p>");
    //            sb.AppendLine("<p>请尽快处理!</p>");
    //        }
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
   
    //}
    internal class EmailForNormalNotifyHandle<T> : BaseEmailHandle<T>
    {
        public override WaitWorkItem Process(T context)
        {
            NormalNotifyEmail emailctx = context as NormalNotifyEmail;
            WaitWorkItem data = new WaitWorkItem();
            var ctx = new EmailContext();
            ctx.Recipient = emailctx.Recipient;
            Prepare(ctx, "notify");
            ctx.Subject = String.Format("{0} -- {1}", SiteResource.SiteName,emailctx.Title);
            ctx.Body = emailctx.Message;
            data.Context = ctx;

            #region 赋值Action
            data.Action = o => { SendMailCallBack(o as EmailContext); };
            #endregion

            return data;
        }
    }
    //internal class EmailForPublicationHandle<T> : BaseEmailHandle<T>
    //{

    //    public override WaitWorkItem Process(T context)
    //    {
    //        PublicationEmail emailctx = context as PublicationEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 稿件《{1}》已被录用", SiteResource.SiteName, emailctx.ArticleName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Message, emailctx.Recipient, emailctx.BackUrl);
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(string message, string username, string backurl)
    //    {
    //        string url = "http://" + SiteResource.Domain + backurl;
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>" + message + "</p>");
    //        if (!String.IsNullOrEmpty(backurl))
    //        {
    //            sb.AppendLine("<p>您可以使用如下链接登陆到我们的网站，并进行后续的操作<br/><a href=\"" + url + "\">" + url + "</a></p>");
    //            sb.AppendLine("<p>请尽快处理!</p>");
    //        }
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
    //}
    #endregion

    #region Job
    //internal class EmailForExamineJobDistributionHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        ZhuanShenJobEmail emailctx = context as ZhuanShenJobEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 《{1}》发来专审稿件", SiteResource.SiteName, emailctx.JournalName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Message,emailctx.ExamineFinishDate, emailctx.JournalName, emailctx.Recipient, emailctx.BackUrl);
    //        ctx.attachments = new List<string>() { 
    //            //emailctx.ExamineSheetPath,
    //            emailctx.ManuscriptPath
    //        };
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(string message,DateTime finishDate, string journalName, string username, string backurl)
    //    {
    //        string url = "http://" + SiteResource.Domain + backurl;
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>《" + journalName + "》发来一份稿件需要您参与专审工作，附件中为稿件，需要您下载稿件并开始审稿工作。</p>");
    //        sb.AppendLine("<p>请您务必于<b>"+finishDate.ToLongDateString()+"</b>前完成专审工作。</p>");
    //        sb.AppendLine("<p>当您完成审核过后，请通过如下链接根据提示提交您的审核结果（或审稿单）。我们会将您的审核结果发送给主办方。</p>");
    //        sb.AppendLine("<p><a href=\"" + url + "\">" + url + "</a></p>");
    //        sb.AppendLine("<p>谢谢!</p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
    //}
    //internal class EmailForUrgeExamineHandle<T> : BaseEmailHandle<T>
    //{
    //    public override WaitWorkItem Process(T context)
    //    {
    //        ZhuanShenJobEmail emailctx = context as ZhuanShenJobEmail;
    //        WaitWorkItem data = new WaitWorkItem();
    //        var ctx = new EmailContext();
    //        ctx.Recipient = emailctx.Recipient;
    //        Prepare(ctx, "notify");
    //        ctx.Subject = String.Format("{0} -- 《{1}》催促您尽快审稿", SiteResource.SiteName, emailctx.JournalName);
    //        ctx.Body = BuildNotityEmailBody(emailctx.Message, emailctx.ExamineFinishDate, emailctx.JournalName, emailctx.Recipient, emailctx.BackUrl);
    //        ctx.attachments = new List<string>() { 
    //            emailctx.ExamineSheetPath,
    //            emailctx.ManuscriptPath
    //        };
    //        data.Context = ctx;

    //        #region 赋值Action
    //        data.Action = o => { SendMailCallBack(o as EmailContext); };
    //        #endregion

    //        return data;
    //    }
    //    public string BuildNotityEmailBody(string message, DateTime finishDate, string journalName, string username, string backurl)
    //    {
    //        string url = "http://" + SiteResource.Domain + backurl;
    //        StringBuilder sb = new StringBuilder();
    //        sb.AppendLine("<style type=\"text/css\">");
    //        sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
    //        sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
    //        sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
    //        sb.AppendLine(".content-line-right{float: right;}");
    //        sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
    //        sb.AppendLine(".content-logo{}");
    //        sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
    //        sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
    //        sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
    //        sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
    //        sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
    //        sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
    //        sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
    //        sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
    //        sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
    //        sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
    //        sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
    //        sb.AppendLine(".content-footer-left{float: left;}");
    //        sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
    //        sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
    //        sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
    //        sb.AppendLine("</style>");
    //        sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
    //        sb.AppendLine("<img src=\"http://" + SiteResource.Domain + SiteResource.Logo + "\" /></div>");
    //        sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
    //        sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
    //        sb.AppendLine("<p>" + username + "，<br/>您好！</p>");
    //        sb.AppendLine("<p>《" + journalName + "》 希望您尽快完成此稿件的审核工作，附件中为稿件和审稿单，需要您下载稿件并根据审核意见填写审稿单。</p>");
    //        sb.AppendLine("<p>请您务必于<b>" + finishDate.ToLongDateString() + "</b>前完成专审工作。</p>");
    //        sb.AppendLine("<p>如果您已经完成了审核，请通过如下链接根据提示提交您的审核结果。我们会将您的审核结果发送给主办方，并记录您的审稿信息以维护您的利益。</p>");
    //        sb.AppendLine("<p><a href=\"" + url + "\">" + url + "</a></p>");
    //        sb.AppendLine("<p>谢谢!</p>");
    //        sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteResource.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
    //        sb.AppendLine("<a href=\"http://" + SiteResource.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
    //        sb.AppendLine("地址：" + SiteResource.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteResource.CompanyPhone);
    //        sb.AppendLine("</div></div></div></div>");
    //        return sb.ToString();
    //    }
    //}
    #endregion
}
